/*
 * Copyright 2012 Alibaba.com All right reserved. This software is the
 * confidential and proprietary information of Alibaba.com ("Confidential
 * Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with Alibaba.com.
 */
package jim.h.commons;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;

/**
 * @author jinggang.huangjg 2012-4-18 下午3:30:06
 */
public class MailNoTest {

    public static void main(String[] args) throws JsonParseException, JsonMappingException, IOException {
        String corpsJson = "[[\"AAEWEB\",\"AAE全球专递\"],[\"ANJELEX\",\"安捷快递\"],[\"ANXINDA\",\"安信达快递\"],[\"APEX\",\"全一快递\"],[\"ATEXPRESS\",\"全日通快递\"],[\"BHTEXP\",\"华慧快递\"],[\"BLUEDART\",\"蓝镖快递\"],[\"BROADASIA\",\"亚风速递\"],[\"CAE\",\"民航快递\"],[\"CCES\",\"CCES快递\"],[\"CHINADRAGON\",\"华夏龙物流\"],[\"CNGLS\",\"GLS快递\"],[\"CNPL\",\"中邮物流\"],[\"COE\",\"中国东方（COE）\"],[\"CORPINIT\",\"个体经营\"],[\"CRE\",\"中铁快运\"],[\"DEPPON\",\"德邦物流\"],[\"DEXP\",\"D速快递\"],[\"DHL\",\"DHL\"],[\"DPEX\",\"DPEX\"],[\"DTW\",\"大田陆运\"],[\"EBONEXP\",\"一邦速递\"],[\"EES\",\"百福东方\"],[\"EMS\",\"EMS\"],[\"EWINSHINE\",\"万象物流\"],[\"F5XM\",\"伍圆速递\"],[\"FASTEXPRESS\",\"快捷速递\"],[\"FEDEX\",\"FedEx\"],[\"FKD\",\"飞康达物流\"],[\"GDEMS\",\"广东邮政物流\"],[\"GPWL\",\"贵平物流\"],[\"GSD\",\"共速达物流\"],[\"GZWENJIE\",\"文捷航空速递\"],[\"HENGLU\",\"恒路物流\"],[\"HOAU\",\"天地华宇\"],[\"HTKY\",\"汇通快运\"],[\"JIAJI\",\"佳吉快运\"],[\"JIAYI\",\"佳怡物流\"],[\"JOUST\",\"急先达\"],[\"KKE\",\"京广速递\"],[\"LBEX\",\"龙邦物流\"],[\"LTS\",\"联昊通物流\"],[\"MANCO\",\"万家物流\"],[\"ND56\",\"港中能达物流\"],[\"PEISI\",\"配思货运\"],[\"PEWKEE\",\"彪记快递\"],[\"PHOENIXEXP\",\"凤凰快递\"],[\"QCKD\",\"全晨快递\"],[\"QUANJT\",\"全际通物流\"],[\"SFEXPRESS\",\"顺丰速运\"],[\"SFWL\",\"盛丰物流\"],[\"SHENGHUI\",\"盛辉物流\"],[\"STARS\",\"星晨急便\"],[\"STO\",\"申通快递\"],[\"SUNDAPOST\",\"上大物流\"],[\"SURE\",\"速尔物流\"],[\"SUYUE\",\"苏粤货运\"],[\"TMS\",\"加运美\"],[\"TNT\",\"TNT\"],[\"TTKDEX\",\"海航天天快递（上海）有限公司\"],[\"UC56\",\"优速物流\"],[\"UPS\",\"UPS\"],[\"XBWL\",\"新邦物流\"],[\"XFEXPRESS\",\"信丰物流\"],[\"XFHEX\",\"鑫飞鸿物流快递\"],[\"YADEX\",\"源安达\"],[\"YCGWL\",\"远成物流\"],[\"YFEXPRESS\",\"越丰物流\"],[\"YFHEX\",\"原飞航物流\"],[\"YJKD\",\"元智捷诚快递\"],[\"YTEXPRESS\",\"运通快递\"],[\"YTO\",\"圆通速递\"],[\"YUNDA\",\"上海韵达货运有限公司\"],[\"YWFEX\",\"源伟丰快递\"],[\"ZJS\",\"宅急送\"],[\"ZTO\",\"中通速递\"],[\"ZTWL\",\"中铁物流\"],[\"EYB\",\"e邮宝\"]]";
        String taobaoCorpsJson = "{\"logistics_partners_get_response\":{\"logistics_partners\":{\"logistics_partner\":[{\"partner\":{\"account_no\":\"20880015515498130156\",\"company_code\":\"ZTO\",\"company_id\":500,\"full_name\":\"中通速递服务有限公司\",\"company_name\":\"中通速递\",\"reg_mail_no\":\"^((618|680|688|618|828|988|118|888|571|518|010|628|205|880|717|718|728|761|762|701|757)[0-9]{9})$|^((2008|2010|8050|7518)[0-9]{8})$\",\"wangwang_id\":\"中通在线客服\"}},{\"partner\":{\"account_no\":\"20880015552542160156\",\"company_code\":\"TTKDEX\",\"company_id\":504,\"full_name\":\"海航天天快递有限公司\",\"company_name\":\"海航天天快递\",\"reg_mail_no\":\"^[0-9]{14}$\",\"wangwang_id\":\"天天快递客服中心\"}},{\"partner\":{\"account_no\":\"20880015025101670156\",\"company_code\":\"YTO\",\"company_id\":101,\"full_name\":\"上海圆通速递有限公司\",\"company_name\":\"圆通速递\",\"reg_mail_no\":\"^(0|1|2|3|5|6|7|8|E|D|F|G|V|W|e|d|f|g|v|w)[0-9]{9}$\",\"wangwang_id\":\"圆通客户服务\"}},{\"partner\":{\"account_no\":\"20880015028650140156\",\"company_code\":\"YUNDA\",\"company_id\":102,\"full_name\":\"上海韵达货运有限公司\",\"company_name\":\"韵达快运\",\"reg_mail_no\":\"^[\\\\s]*[0-9]{13}[\\\\s]*$\",\"wangwang_id\":\"韵达在线客服\"}},{\"partner\":{\"account_no\":\"\",\"company_code\":\"EYB\",\"company_id\":3,\"full_name\":\"中国速递服务公司\",\"company_name\":\"e邮宝\",\"reg_mail_no\":\"^[C,E][A-Z][0-9]{9}[C][N,S]$\",\"wangwang_id\":\"中国邮政011\"}},{\"partner\":{\"account_no\":\"20880015028911270156\",\"company_code\":\"ZJS\",\"company_id\":103,\"full_name\":\"北京宅急送快运股份有限公司\",\"company_name\":\"宅急送\",\"reg_mail_no\":\"^[a-zA-Z0-9]{10}$\",\"wangwang_id\":\"宅急送客服\"}},{\"partner\":{\"account_no\":\"\",\"company_code\":\"CNEX\",\"company_id\":1056,\"full_name\":\"上海佳吉快运有限公司\",\"company_name\":\"佳吉快运\",\"reg_mail_no\":\"^[0-9]{10}$\",\"wangwang_id\":\"佳吉在线客服\"}},{\"partner\":{\"account_no\":\"20880014978728840156\",\"company_code\":\"STO\",\"company_id\":100,\"full_name\":\"申通快递有限公司\",\"company_name\":\"申通E物流\",\"reg_mail_no\":\"^(268|888|588|688|368|468|568|668|768|868|968)[0-9]{9}$|^(268|888|588|688|368|468|568|668|768|868|968)[0-9]{10}$|^(STO)[0-9]{10}$\",\"wangwang_id\":\"申通在线客服\"}},{\"partner\":{\"account_no\":\"\",\"company_code\":\"EMS\",\"company_id\":2,\"full_name\":\"中国速递服务公司\",\"company_name\":\"EMS\",\"reg_mail_no\":\"^[A-Z]{2}[0-9]{9}[A-Z]{2}$\",\"wangwang_id\":\"中国邮政010\"}},{\"partner\":{\"account_no\":\"20881015395592840156\",\"company_code\":\"FEDEX\",\"company_id\":106,\"full_name\":\"联邦快递(中国)有限公司\",\"company_name\":\"联邦快递\",\"reg_mail_no\":\"^[0-9]{12}$\",\"wangwang_id\":\"联邦在线客服\"}},{\"partner\":{\"account_no\":\"20881015683414450156\",\"company_code\":\"SHQ\",\"company_id\":108,\"full_name\":\"深圳华强物流有限公司\",\"company_name\":\"华强物流\",\"reg_mail_no\":\"^[A-Za-z0-9]*[0|2|4|6|8]$\",\"wangwang_id\":\"华强在线客服\"}},{\"partner\":{\"account_no\":\"20881015920158220156\",\"company_code\":\"HTKY\",\"company_id\":502,\"full_name\":\"杭州百世网络技术有限公司（汇通快运）\",\"company_name\":\"汇通快运\",\"reg_mail_no\":\"^(A|B|C|D|E|H|0)(D|X|[0-9])(A|[0-9])[0-9]{10}$|^(21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39)[0-9]{10}$\",\"wangwang_id\":\"汇通在线客服\"}},{\"partner\":{\"company_code\":\"DEPPON\",\"company_id\":1141,\"full_name\":\"上海德邦物流有限公司\",\"company_name\":\"德邦物流家装\",\"reg_mail_no\":\"^[0-9]?[0-9]{7}$\",\"wangwang_id\":\"德邦物流平台\"}},{\"partner\":{\"company_code\":\"SZCWOL\",\"company_id\":1150,\"full_name\":\"深圳市赤湾东方物流有限公司\",\"company_name\":\"赤湾东方\",\"reg_mail_no\":\"^[A-Za-z]{4}[0-9]{11}$\",\"wangwang_id\":\"collionc\"}},{\"partner\":{\"account_no\":\"\",\"company_code\":\"ZTKY\",\"company_id\":1152,\"full_name\":\"中铁物流集团有限公司\",\"company_name\":\"中铁物流\",\"reg_mail_no\":\"^[A-Za-z]{2}[0-9]{7}$\",\"wangwang_id\":\"yangqian_ztky\"}},{\"partner\":{\"account_no\":\"20881015930773220156\",\"company_code\":\"DBL\",\"company_id\":107,\"full_name\":\"德邦物流股份有限公司\",\"company_name\":\"德邦物流\",\"reg_mail_no\":\"^[0-9]?[0-9]{7}$\",\"wangwang_id\":\"德邦在线客服\"}},{\"partner\":{\"company_code\":\"XNGX\",\"company_id\":1187,\"full_name\":\"家装馆干线物流\",\"company_name\":\"家装干线物流\",\"reg_mail_no\":\".*\",\"wangwang_id\":\"ifc_长绪\"}},{\"partner\":{\"company_code\":\"HOAU\",\"company_id\":1191,\"full_name\":\"黑龙江省五洲华宇恒业物流有限公司\",\"company_name\":\"天地华宇\",\"reg_mail_no\":\"^[0-9]{8}$\",\"wangwang_id\":\"天地华宇01\"}},{\"partner\":{\"company_code\":\"NEDA\",\"company_id\":1192,\"full_name\":\"广东港中能达物流有限公司\",\"company_name\":\"港中能达\",\"reg_mail_no\":\"^((88|)[0-9]{10})$|^((1|2|3|5|)[0-9]{9})$\",\"wangwang_id\":\"港中能达总部\"}},{\"partner\":{\"account_no\":\"20881015395592840156\",\"company_code\":\"FEDEXLY\",\"company_id\":1193,\"full_name\":\"联邦快递普达\",\"company_name\":\"联邦快递陆运\",\"reg_mail_no\":\"^[0-9]{12}$\",\"wangwang_id\":\"联邦在线客服\"}},{\"partner\":{\"company_code\":\"XB\",\"company_id\":1186,\"full_name\":\"广东新邦物流有限公司\",\"company_name\":\"新邦物流\",\"reg_mail_no\":\"[0-9]{8}\",\"wangwang_id\":\"gdgzxbwl\"}},{\"partner\":{\"company_code\":\"XFHONG\",\"company_id\":1194,\"full_name\":\"北京顺达鑫飞鸿物流有限公司\",\"company_name\":\"鑫飞鸿快递\",\"reg_mail_no\":\"^[0-9]{10,}$\",\"wangwang_id\":\"北京鑫飞鸿\"}},{\"partner\":{\"account_no\":\"2088601048193064\",\"company_code\":\"FAST\",\"company_id\":1204,\"full_name\":\"广东快捷快物流有限公司\",\"company_name\":\"快捷速递\",\"reg_mail_no\":\"^[0-9]{11,13}$\",\"wangwang_id\":\"项目部326\"}},{\"partner\":{\"account_no\":\"\",\"company_code\":\"YF\",\"company_id\":1206,\"full_name\":\"深圳市亚风速递有限公司\",\"company_name\":\"亚风速递\",\"reg_mail_no\":\"^[0-9]{10}$\",\"wangwang_id\":\"亚风在线咨询\"}},{\"partner\":{\"account_no\":\"20886012924552110156\",\"company_code\":\"UC\",\"company_id\":1207,\"full_name\":\"广东优速物流有限公司\",\"company_name\":\"优速物流\",\"reg_mail_no\":\"^VIP[0-9]{9}|V[0-9]{11}|[0-9]{12}$\",\"wangwang_id\":\"优速物流01\"}},{\"partner\":{\"company_code\":\"QRT\",\"company_id\":1208,\"full_name\":\"广州市全日通物流有限公司\",\"company_name\":\"全日通快递\",\"reg_mail_no\":\"^[0-9]{12}$\",\"wangwang_id\":\"gzqrt\"}},{\"partner\":{\"account_no\":\"20885019026795440156\",\"company_code\":\"LTS\",\"company_id\":1214,\"full_name\":\"东莞市联昊通速递有限公司\",\"company_name\":\"联昊通\",\"reg_mail_no\":\"^[0-9]{9,12}$\",\"wangwang_id\":\"联昊通速递公司\"}},{\"partner\":{\"company_code\":\"YCT\",\"company_id\":1185,\"full_name\":\"雅玛多（中国）运输有限公司\",\"company_name\":\"黑猫宅急便\",\"reg_mail_no\":\"^[0-9]{12}$\",\"wangwang_id\":\"黑猫宅急便yct\"}},{\"partner\":{\"account_no\":\"2088601098507363\",\"company_code\":\"QFKD\",\"company_id\":1216,\"full_name\":\"北京全峰快递有限责任公司\",\"company_name\":\"全峰快递\",\"reg_mail_no\":\"^[0-9]{12}$\",\"wangwang_id\":\"全峰速递\"}},{\"partner\":{\"account_no\":\"lbexceo@126.com\",\"company_code\":\"LBEX\",\"company_id\":510,\"full_name\":\"广东龙邦物流有限公司\",\"company_name\":\"龙邦快递\",\"reg_mail_no\":\"^[0-9]{12}$\",\"wangwang_id\":\"广东龙邦物流有限公司\"}},{\"partner\":{\"account_no\":\"20886010376328860156\",\"company_code\":\"LB\",\"company_id\":1195,\"full_name\":\"广东龙邦物流有限公司\",\"company_name\":\"龙邦物流\",\"reg_mail_no\":\"^[0-9]{12}$\",\"wangwang_id\":\"广东龙邦物流有限公司\"}},{\"partner\":{\"account_no\":\"20881010863049460156\",\"company_code\":\"BEST\",\"company_id\":105,\"full_name\":\"百世物流科技有限公司\",\"company_name\":\"百世物流\",\"reg_mail_no\":\"^[0-9]{10}$\",\"wangwang_id\":\"百世在线客服\"}},{\"partner\":{\"account_no\":\"20887010020603300156\",\"company_code\":\"SCKJ\",\"company_id\":1236,\"full_name\":\"成都东骏快捷物流有限公司\",\"company_name\":\"四川快捷\",\"reg_mail_no\":\"^[0-9]{13}$\",\"wangwang_id\":\"东骏006\"}},{\"partner\":{\"company_code\":\"HTKYT\",\"company_id\":1257,\"full_name\":\"汇通快运测试\",\"company_name\":\"汇通测试\",\"reg_mail_no\":\"^(A|B|C|D|H|Z|0)(D|X|[0-9])(A|[0-9])[0-9]{10}$\",\"wangwang_id\":\"承嗣\"}},{\"partner\":{\"account_no\":\"20881017400270370156\",\"company_code\":\"SF\",\"company_id\":505,\"full_name\":\"顺丰速运（集团）有限公司\",\"company_name\":\"顺丰速运\",\"reg_mail_no\":\"^[0-9]{12}$\",\"wangwang_id\":\"顺丰在线客服\"}},{\"partner\":{\"account_no\":\"2088701511805543\",\"company_code\":\"UAPEX\",\"company_id\":1259,\"full_name\":\"上海全毅快递有限公司\",\"company_name\":\"全一快递\",\"reg_mail_no\":\"^\\\\d{12}$\",\"wangwang_id\":\"unitop全一\"}},{\"partner\":{\"company_code\":\"shcc\",\"company_id\":201,\"full_name\":\"上海配送中心\",\"company_name\":\"上海配送中心\",\"reg_mail_no\":\"^(268|888|588|688|368|468|568|668|768|868|968)[0-9]{9}$|^(268|888|588|688|368|468|568|668|768|868|968)[0-9]{10}$|^(STO)[0-9]{10}$|^[A-Z]{2}[0-9]{9}[A-Z]{2}$\",\"wangwang_id\":\"林蒙\"}},{\"partner\":{\"account_no\":\"20882018319961350156\",\"company_code\":\"CCES\",\"company_id\":501,\"full_name\":\"上海希伊艾斯快递有限公司\",\"company_name\":\"CCES\",\"reg_mail_no\":\"^(2|3|5|6|8|5|1)[0-9]{9}$\",\"wangwang_id\":\"cces在线客服\"}},{\"partner\":{\"company_code\":\"CRE\",\"company_id\":1016,\"full_name\":\"中铁快运股份有限公司\",\"company_name\":\"中铁快运\",\"reg_mail_no\":\"^K[0-9]{13}$\",\"wangwang_id\":\"中铁快运客服\"}},{\"partner\":{\"account_no\":\"20882015664543130156\",\"company_code\":\"STARS\",\"company_id\":1007,\"full_name\":\"北京星晨急便速递有限公司\",\"company_name\":\"星晨急便\",\"reg_mail_no\":\"^[0-9]{10}$\",\"wangwang_id\":\"星晨急便客服\"}},{\"partner\":{\"account_no\":\"20882018753585220156\",\"company_code\":\"EBON\",\"company_id\":1036,\"full_name\":\"一邦速递有限公司\",\"company_name\":\"一邦(CCES)\",\"reg_mail_no\":\"^[0-9]{10}$\",\"wangwang_id\":\"一邦速递客服\"}}]}}}";
        ObjectMapper mapper = new ObjectMapper();
        List<Map<String, Map<String, Object>>> taobaoCorps = (List<Map<String, Map<String, Object>>>) ((Map) ((Map) mapper.readValue(taobaoCorpsJson,
                                                                                                                                     Map.class).get("logistics_partners_get_response")).get("logistics_partners")).get("logistics_partner");
        List<List<String>> corps = mapper.readValue(corpsJson, List.class);

        List<String> corpsNotMatched = new ArrayList<String>();
        int i = 0;
        for (List<String> corp : corps) {
            boolean found = false;
            for (Map<String, Map<String, Object>> taobaoCorp : taobaoCorps) {
                if (taobaoCorp.get("partner").get("full_name").toString().contains(corp.get(1).substring(0, 2))) {
                    System.out.println(corp.get(0) + ":" + taobaoCorp.get("partner").get("reg_mail_no"));
                    found = true;
                }
            }
            if (found) {
                i++;
            } else {
                corpsNotMatched.add(corp.get(1));
            }
        }
        System.out.println("\n\n一共有 " + corps.size() + " 家公司，匹配了 " + i + " 家公司");
        System.out.println("其中未找到的公司如下:");
        for (String corp : corpsNotMatched) {
            System.out.println(corp);
        }
    }
}
